﻿using System;
using System.Collections.Generic;
using System.Text;

namespace AndersLiu.PE
{
    public enum ImageFileMachine : ushort
    {
        UNKNOWN = 0,
        I386 = 0x014c,  // Intel 386.
        R3000 = 0x0162,  // MIPS little-endian, = 0x160 big-endian
        R4000 = 0x0166,  // MIPS little-endian
        R10000 = 0x0168,  // MIPS little-endian
        WCEMIPSV2 = 0x0169,  // MIPS little-endian WCE v2
        ALPHA = 0x0184,  // Alpha_AXP
        SH3 = 0x01a2,  // SH3 little-endian
        SH3DSP = 0x01a3,
        SH3E = 0x01a4,  // SH3E little-endian
        SH4 = 0x01a6,  // SH4 little-endian
        SH5 = 0x01a8,  // SH5
        ARM = 0x01c0,  // ARM Little-Endian
        THUMB = 0x01c2,
        AM33 = 0x01d3,
        POWERPC = 0x01F0,  // IBM PowerPC Little-Endian
        POWERPCFP = 0x01F1,
        IA64 = 0x0200,  // Intel 64
        MIPS16 = 0x0266,  // MIPS
        ALPHA64 = 0x0284,  // ALPHA64
        MIPSFPU = 0x0366,  // MIPS
        MIPSFPU16 = 0x0466,  // MIPS
        AXP64 = ALPHA64,
        TRICORE = 0x0520,  // Infineon
        CEF = 0x0CEF,
        EBC = 0x0EBC,  // EFI Byte Code
        AMD64 = 0x8664,  // AMD64 (K8)
        M32R = 0x9041,  // M32R little-endian
        CEE = 0xC0EE,
    }

    [Flags]
    public enum ImageFileCharacteristics : ushort
    {
        RelocsStripped = 0x0001,
        ExecutableImage = 0x0002,
        LineNumsStripped = 0x0004,
        LocalSymsStripped = 0x0008,
        AggresiveWsTrim = 0x0010,
        LargeAddressAware = 0x0020,
        BytesReversedLo = 0x0080,
        Is32BitMachine = 0x0100,
        DebugStripped = 0x0200,
        RemovableRunFromSwap = 0x0400,
        NetRunFromSwap = 0x0800,
        System = 0x1000,
        Dll = 0x2000,
        UpSystemOnly = 0x4000,
        BytesReversedHi = 0x8000,
    }

    public enum ImageOptionalHeaderMagic : ushort
    {
        NtOptionalHeader32 = 0x010B,
        NtOptionalHeader64 = 0x020B,
        RomOptionalHeader = 0x0107,
    }

    public enum ImageSubsystem : ushort
    {
        Unknown = 0,
        Native = 1,
        WindowsGui = 2,
        WindowsCui = 3,
        OS2Cui = 5,
        PosixCui = 7,
        NativeWindows = 8,
        WindowsCEGui = 9,
        EfiApplication = 10,
        EfiBootServiceDriver = 11,
        EfiRuntimeDriver = 12,
        EfiRom = 13,
        Xbox = 14,
    }

    [Flags]
    public enum ImageDllCharacteristics : ushort
    {
        NoIsolation = 0x0200,
        NoSeh = 0x0400,
        NoBind = 0x0800,
        WdmDriver = 0x2000,
        TerminalServerAware = 0x8000,
    }

    [Flags]
    public enum ImageSectionCharacteristics : uint
    {
        TypeReg = 0x00000000,
        TypeDsect = 0x00000001,
        TypeNoLoad = 0x00000002,
        TypeGroup = 0x00000004,
        TypeNoPad = 0x00000008,
        TypeCopy = 0x00000010,
        ContainsCode = 0x00000020,
        ContainsInitializedData = 0x00000040,
        ContainsUninitializedData = 0x00000080,
        LinkerOther = 0x00000100,
        LinkerInfo = 0x00000200,
        TypeOver = 0x00000400,
        LinkerRemove = 0x00000800,
        LinkerComdat = 0x00001000,
        Reserved = 0x00002000,
        MemoryProtected = 0x00004000,
        NoDeferSpeculativeExceptions = 0x00004000,
        GpRelative = 0x00008000,
        MemoryFarData = 0x00008000,
        MemorySysHeap = 0x00010000,
        MemoryPurgeable = 0x00020000,
        Memory16Bit = 0x00020000,
        MemoryLocked = 0x00040000,
        MemoryPreload = 0x00080000,
        Align1Bytes = 0x00100000,
        Align2Bytes = 0x00200000,
        Align4Bytes = 0x00300000,
        Align8Bytes = 0x00400000,
        Align16Bytes = 0x00500000,
        Align32Bytes = 0x00600000,
        Align64Bytes = 0x00700000,
        Align128Bytes = 0x00800000,
        Align256Bytes = 0x00900000,
        Align512Bytes = 0x00A00000,
        Align1024Bytes = 0x00B00000,
        Align2048Bytes = 0x00C00000,
        Align4096Bytes = 0x00D00000,
        Align8192Bytes = 0x00E00000,
        AlignMask = 0x00F00000,
        LinkerNrelocOvfl = 0x01000000,
        MemoryDiscardable = 0x02000000,
        MemoryNotCached = 0x04000000,
        MemoryNotPaged = 0x08000000,
        MemoryShared = 0x10000000,
        MemoryExecute = 0x20000000,
        MemoryRead = 0x40000000,
        MemoryWrite = 0x80000000,
    }

    [Flags]
    public enum ComImageFlags : uint
    {
        ILOnly = 0x00000001,
        Is32BitRequired = 0x00000002,
        ILLibrary = 0x00000004,
        StrongNameSigned = 0x00000008,
        TrackDebugData = 0x00010000,
    }
}
